package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

@Mapper
public interface OrderMapper {
    void insert(Orders orders);

    /**
     * 根据订单号查询订单
     *
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    void update(Orders orders);
/*
分页查询订单
 */

    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    OrderStatisticsVO statistics();

    @Select("SELECT * FROM  orders WHERE id=#{id}")
    Orders getById(Long id);

    /**
     * 更具订单状态和订单时间查询订单详细
     * @param status
     * @param OrderTime
     * @return
     */
    @Select("SELECT * from orders where status=#{status} and order_time<(#{OrderTime})")
    List<Orders> getByStatusAndTime(Integer status, LocalDateTime OrderTime);
    List<OrderDetail> detailPageQuery(List<Long> listOrderId);
}
